using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace MosziNET.Web.Gallery
{
    /// <summary>
    /// Helper methods
    /// </summary>
    internal static class HelperMethods
    {

        // The format to be used when building the thumbnail url
        private static string imageUrlFormat = "~/{0}?{1}={2}&{3}={4}&{5}={6}&{7}={8}";

        /// <summary>
        /// Generates the Url for returning the image from the persistence medium
        /// </summary>
        /// <param name="image"></param>
        /// <param name="folderId"></param>
        /// <param name="isFolder"></param>
        /// <param name="isThumbnail"></param>
        /// <returns></returns>
        public static string GetImageUrl(FolderImage image, string folderId,
            bool isFolder, bool isThumbnail)
        {
            if (!String.IsNullOrEmpty(image.ParentFolder))
                folderId = image.ParentFolder;

            return String.Format(CultureInfo.InvariantCulture,
                imageUrlFormat, GalleryManager.ImageHandlerFile,
                Properties.Resources.Parameter_FolderId, folderId,
                Properties.Resources.Parameter_ImageName, image.ImageName,
                Properties.Resources.Parameter_IsFolder, isFolder ? "1" : "0",
                Properties.Resources.Parameter_IsThumbnail, isThumbnail ? "1" : "0");
        }
    }
}
